//
//  PointsListViewController.swift
//  ezyform
//
//  Created by MoennigQ on 30/12/19.
//  Copyright © 2019 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit
import MBProgressHUD
import SwiftyJSON
import HandyJSON
class PointDescriptionViewController: ModelBaseViewController {
    
    let customView = PointDescriptionView()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view = customView
        self.customView.setTitle(R.string.localizable.meInstallerpointsDescription())
        
        self.customView.closeBtn.addTarget(self, action: #selector(dismissVC), for: UIControl.Event.touchUpInside)
        self.loadData()
    }
    func loadData(){
        let vc = PointService()
        
        vc.setBlockAfterNetwork({ (obj , _) in
            ModelViewUtil.shared.hideLoadingView()
            if let result = obj {
                let json = JSON(result)
                if let list = (JSONDeserializer<PointDescriptionModel>.deserializeModelArrayFrom(json: json.rawString()) as? Array<PointDescriptionModel>){
                    self.customView.list = list
                }
                self.customView.tableView.reloadData()
                
            }
            
        }) { (code,err) in
            ModelViewUtil.shared.hideLoadingView()
            Tool().showErrorInfo(code,err)
        }
        ModelViewUtil.shared.showLoadingView( NSLocalizedString("Loading", comment: ""))
        vc.getPointDescription()
    }
}
